<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"      
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">
	
    <h:body>	
		<ui:composition template="/admin/template.xhtml">		    			
		<p:panel header="Editace odkazů">	
			<h:panelGrid columns="2">
				<p:panel header="Odkazy" style="min-height: 1129px;">   
				   <h:form id="odkazyForm">	
					    	<p:dataTable id="seaspmTable" var="link" value="#{linkBean.allLinks}" rowKey="#{link.id}" paginator="true" rows="15" paginatorAlwaysVisible="false" paginatorPosition="bottom" selection="#{linkBean.selectedLink}" selectionMode="single" emptyMessage="Žádné odkazy nenalazeny"  tableStyle="min-width:300px;">
						        <f:facet name="header">
									<h:outputText value="Seznam odkazů" />
						        </f:facet>
						        <p:column>  
						            <h:outputText value="#{link.name}" />  
						        </p:column>
						        <f:facet name="footer">  
					            	<p:commandButton  id="editLinkButton" icon="ui-icon-pencil" value="upravit odkaz" update=":linkEditDialog" oncomplete="linkEditDialog.show()"/>
					                <p:commandButton  id="newLinkButton" icon="ui-icon-document" value="nový odkaz"  update=":odkazyForm" oncomplete="linkNewDialog.show()"/>     
									<p:commandButton value="Odstranit"  actionListener="#{linkBean.deleteLink}" update=":odkazyForm,:growl" />					       		
					       		</f:facet>   
					  	    </p:dataTable>
					</h:form>
					
					
					
					<p:dialog id="linkNewDialog" header="Nový odkaz" widgetVar="linkNewDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid columns="2" cellpadding="4">
						      	       <h:outputText value="Název:" />    						      
							           <h:inputText id="newLinkName" value="#{linkBean.newLink.name}" style="width:150px"/>  
							           <h:outputText value="Popis:" />    						      
							           <h:inputText id="newLinkContant" value="#{linkBean.newLink.content}" style="width:150px"/>
							           <h:outputText value="Url:" />    						      
							           <h:inputText id="newUrlName" value="#{linkBean.newLink.url}" style="width:150px"/>  	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Vytvoř odkaz"  actionListener="#{linkBean.createLink}" update=":odkazyForm,:linkNewDialog,:growl" oncomplete="linkNewDialog.hide()" />
						        </h:form>	
					</p:dialog>
					
					<p:dialog id="linkEditDialog" header="Editovat odkaz" widgetVar="linkEditDialog" resizable="false"  
					              width="300" showEffect="clip" hideEffect="fold" position="10,10">  
						      	 <h:form>   
						      	    <h:panelGrid columns="2" cellpadding="4">
						      	       <h:outputText value="Název:" />    						      
							           <h:inputText id="newLinkName" value="#{linkBean.selectedLink.name}" style="width:150px"/>  
							           <h:outputText value="Popis:" />    						      
							           <h:inputText id="newLinkContant" value="#{linkBean.selectedLink.content}" style="width:150px"/>
							           <h:outputText value="Url:" />    						      
							           <h:inputText id="newUrlName" value="#{linkBean.selectedLink.url}" style="width:150px"/>	 
						        	</h:panelGrid> 
						        	<p:commandButton value="Ulož změny"  actionListener="#{linkBean.updateLink}" update=":odkazyForm,:growl" oncomplete="linkEditDialog.hide()"/>  
						        </h:form>	
					 </p:dialog>
					
				</p:panel>
			</h:panelGrid>
		</p:panel>			
		</ui:composition>	
	</h:body>
</html>